package cn.dkk.behavior_design.iterator;

/**
 * @author dkk
 * @date 2022/7/31
 * @desc
 */
public class Test {
    public static void main(String[] args) {
        StudentAggregateImpl studentAggregate = new StudentAggregateImpl();
        StudentIterator iterator = studentAggregate.iterator();
        Student 杜二狗1 = new Student("杜二狗1", "1");
        Student 杜二狗2 = new Student("杜二狗2", "2");
        Student 杜二狗3 = new Student("杜二狗3", "3");
        Student 杜二狗4 = new Student("杜二狗4", "4");
        Student 杜二狗5 = new Student("杜二狗5", "5");
        Student 杜二狗6 = new Student("杜二狗6", "6");
        Student 杜二狗7 = new Student("杜二狗7", "7");
        studentAggregate.add(杜二狗1);
        studentAggregate.add(杜二狗2);
        studentAggregate.add(杜二狗3);
        studentAggregate.add(杜二狗4);
        studentAggregate.add(杜二狗5);
        studentAggregate.add(杜二狗6);
        studentAggregate.add(杜二狗7);
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        studentAggregate.remove(杜二狗5);
        studentAggregate.remove(杜二狗6);
        studentAggregate.remove(杜二狗7);
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
